using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeControl : MonoBehaviour
{

    public int hp = 3;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter(Collider other)
    {
        // 由于场景上只有子弹是触发器, 所以触发的时候碰撞对象必然是子弹
        hp -= 1;
        // 当子弹碰到我的时候就减少hp, hp为0则移除对象
        if (hp <= 0)
        {
            Destroy(this.gameObject);
        }
    }

}
